package com.jingdianjichi.subject.common.enums;

import lombok.Getter;

@Getter
public enum ResultCodeEnum {

   // 添加中文注释后
    SUCCESS(200,"成功"),
    FAIL(500,"失败");

    // 定义一个code属性
    public int code;

    // 定义一个desc属性
    public String desc;

    // 构造函数，传入code和desc
    ResultCodeEnum(int code,String desc){
        this.code = code;
        this.desc = desc;
    }

    // 根据code值获取ResultCodeEnum
    public static ResultCodeEnum getByCode(int codeVal){
        for(ResultCodeEnum resultCodeEnum : ResultCodeEnum.values()){
            if(resultCodeEnum.code == codeVal){
                return resultCodeEnum;
            }
        }
        return null;
    }


}
